Construct an array of first N natural numbers having no triplet (i, j, k) such that a[i] + a[j] = 2* a[k] where i < j< k
Given a positive integer N, the task is to construct an array a[] using first N natural numbers which contains no such triplet (i, j, k) satisfying a[k] * 2 = a[i] + a[j] and i < j < k....
read more
Minimize count of alternating subsequences to divide given Binary String with subsequence number
Given a binary string S of length N. The task is to find the following:...
read more
Minimum cost of reducing Array by merging any adjacent elements repetitively
Given an array arr[] of N numbers. We can merge two adjacent numbers into one and the cost of merging the two numbers is equal to the sum of the two values. The task is to find the total minimum cost of merging all the numbers.Examples:...
read more
Check if given Binary string follows then given condition or not
Given binary string str, the task is to check whether the given string follows the below condition or not:...
read more
OLA Interview Experience | Set 11 ( For Internship)
Round 1 (Online Test): Four Programming Questions- a) Given a string find number of different substrings that are palindromes....
read more
Walmart Labs Interview Experience | Set 15 (For Internship)
Round-1 Online Test Online Test consists of 10 MCQ questions based on OS, DBMS, C and DS. Followed by a coding question which was similar to Kadane’s Algorithm with an extra condition that you can’t leave two consecutive entries. Five students were shortlisted after this round....
read more
Count of substrings in a Binary String that contains more 1s than 0s
Given a binary string s, the task is to calculate the number of such substrings where the count of 1‘s is strictly greater than the count of 0‘s....
read more
Write program to calculate pow(x, n)
Given two integers x and n, write a function to compute xn. We may assume that x and n are small and overflow doesn’t happen....
read more
Kth smallest number in array formed by product of any two elements from two arrays
Given two sorted arrays A[] and B[] consisting of N and M integers respectively, the task is to find the Kth smallest number in the array formed by the product of all possible pairs from array A[] and B[] respectively....
read more
Check if a number N can be expressed in base B
Given a number N and any base B. The task is to check if N can be expressed in the form a1*b0 + a2*b1 + a3*b2 + ….+ a101*b100 where each coefficients a1, a2, a3…a101 are either 0, 1 or -1....
read more
Time and Space Complexity Analysis of Binary Search Algorithm
Time complexity of Binary Search is O(log n), where n is the number of elements in the array. It divides the array in half at each step. Space complexity is O(1) as it uses a constant amount of extra space....
read more
Square root of an integer
Given an integer X, find its square root. If X is not a perfect square, then return floor(√x)....
read more